% This functions returns the 'fitness' of the algorithm

function [popFit, relativeFit] = hw8Fitness(inputData, population)
inputSize = size(inputData,1);
popSize = size(population,1);
popFit = zeros(1, popSize);
for pop=1:popSize
    for inp=1:inputSize
        [hypoSorted] = hw8Sort(inputData(inp,:),population(pop,:));
        if (issorted(hypoSorted))
            % reward 50 for a perfect sort
            popFit(pop) = popFit(pop) + 50;
        end
        % penalize for number of swaps more to be taken
        popFit(pop) = popFit(pop)  - hw8BubbleSort(hypoSorted);        
    end
end



relativeFit = popFit/sum(popFit);
